package com.uml.umlwork.vo.news;

import com.uml.umlwork.entity.News;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.Optional;


@Getter
@Setter
@ToString
@Accessors(chain = true)
public class NewsVO {

    @ApiModelProperty("新闻ID")
    private Integer id;

    @ApiModelProperty("新闻主题")
    private String title;

    @ApiModelProperty("新闻内容")
    private String content;

    @ApiModelProperty("新闻创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty("是否发布")
    private Boolean release;

    public NewsVO(News newses){
        Optional.ofNullable(newses).ifPresent(news -> {
            this.id = news.getId();
            this.title = news.getTitle();
            this.createTime = news.getCreateTime();
            this.content = news.getContent();
            this.release = news.getPublish();
        });
    }
}
